import numpy as np
import argparse
import sys


class SiteStats:
    def __init__(self, strand, pos, chr):

        self._strand = strand
        self._pos = pos
        self._chr = chr
        self._coverage = 0


key_sep = "||"

def caculate_depth(reads_files):
    sitekeys = set()
    sitekey2stats = dict()

    with open(reads_files, 'r') as rf:
        for line in rf:
            words = line.strip().split("\t")
            site_key=key_sep.join([words[0], str(words[1])])

            if site_key not in sitekeys:
                sitekeys.add(site_key)
                sitekey2stats[site_key] = SiteStats(words[2], words[1],words[0])
            sitekey2stats[site_key]._coverage += 1
    cov=[]
    for key in sitekeys:
        cov.append(sitekey2stats[key]._coverage)
    print("mean_covarge: {}".format(np.mean(cov)))

def main():
    parser = argparse.ArgumentParser(description='calculate frequency of interested sites at genome level')
    parser.add_argument('--input', '-i')

    args = parser.parse_args()
    caculate_depth(args.input)

if __name__ == '__main__':
    sys.exit(main())

